/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Controller;

import java.sql.*;
import oracle.jdbc.pool.OracleDataSource;

/**
 * 
 * @author Jeanot Nahasan
 * me@jeanotnahasan.com
 * http://www.jeanotnahasan.com
 */
public class DatabaseHandler {

    static String jdbcUrl = "jdbc:oracle:thin:@localhost:1521:XE";
    static String userid = "rplbo";
    static String password = "rplbo";
    static Connection conn;
    static Statement stmt;
    ResultSet rset;
    String query;
    String sqlString;

    public DatabaseHandler() {
    }

    public static Connection getDBConnection() throws SQLException {
        OracleDataSource ds;
        ds = new OracleDataSource();
        ds.setURL(jdbcUrl);
        conn = ds.getConnection(userid, password);
        return conn;
    }

    public static void update(String query) throws SQLException {

        stmt = getDBConnection().createStatement();
        stmt.executeUpdate(query);
        stmt.close();
    }

    public static ResultSet execute(String query) throws SQLException {
        Statement stm = getDBConnection().createStatement();
        ResultSet result = null;
        result = stm.executeQuery(query);
     
        return result;

    }
}
